package android.app.gfestival.adapter;

import java.util.List;

import android.app.gfestival.R;
import android.app.gfestival.soap.Event;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ProgramSecondAdapter extends BaseAdapter{
		
		private List<Event> list;
		private Context context;

		public ProgramSecondAdapter(Context context, List<Event> list){
			this.list = list;
			this.context = context;
		}
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return list.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return list.get(position);
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parentView) {
			// TODO Auto-generated method stub
			Holder holder = null;
			if(convertView == null){
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				convertView = inflater.inflate(R.layout.program_second_item, null);
				holder = new Holder();
				holder.time = (TextView) convertView.findViewById(R.id.program_time);
				holder.name = (TextView) convertView.findViewById(R.id.textview_name);
				holder.info = (TextView) convertView.findViewById(R.id.textview_info);
				convertView.setTag(holder);
			}else{
				holder = (Holder) convertView.getTag();
			}
			holder.name.setText(list.get(position).artist_name);
			holder.time.setText(list.get(position).event_start_time);
			holder.info.setText(list.get(position).event_place_name);
			return convertView;
		}
		
		private class Holder{
			TextView time;
			TextView name;
			TextView info;
		}
		
	}